<%@ page language="java"  pageEncoding="utf-8"%>
<%@page import="java.nio.charset.Charset"%>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<%@ page import=" java.util.Vector,com.ejoysoft.wlanyz.business.Ap,com.ejoysoft.common.Constants,com.ejoysoft.common.exception.NoRightException" %>
<%@ include file="../include/jsp/head.jsp"%>
<%
if(!globa.userSession.hasRight("20010"))
      throw new NoRightException("用户不具备操作该功能模块的权限，请与系统管理员联系！");
%>
<%
    //初始化
    Ap  Ap0=null;
    Ap obj=new Ap(globa);
    out.println("ssssssssssssssss");
    //查询条件
    String  strMac_Addr=ParamUtil.getString(request,"strMac_Addr","").trim();
	String exportContent = ParamUtil.getString(request,"exportContent","");
    
		//当前页
    int intCurPage = Integer.parseInt(ParamUtil.getString(request,"strCurPage","1"));
	String tWhere=" WHERE 1=1";
    if(!strMac_Addr.equals("")){
     tWhere += " and strMac_Addr LIKE '%"+ strMac_Addr +"%' " ;
    }
	//记录总数
	int intAllCount=obj.getCount(tWhere);	

	//每页记录数
	String strPageSize = ParamUtil.getString(request,"strPageSize","15");
    int intPageSize;
    if(strPageSize.equals("所有"))intPageSize = intAllCount;
      else  intPageSize = Integer.parseInt(strPageSize);
	//共有页数
 	int intPageCount=(intAllCount-1)/intPageSize+1;
	// 循环显示一页内的记录 开始序号
	int intStartNum=(intCurPage-1)*intPageSize+1;
	//结束序号
	int intEndNum=intCurPage*intPageSize;   
	//获取到当前页面的记录集
	Vector<Ap> vctObj=obj.list(tWhere,intStartNum,intPageSize);
	//获取当前页的记录条数
	int intVct=(vctObj!=null&&vctObj.size()>0?vctObj.size():0);
   
		if(exportContent.equals("allPage"))
		{
			vctObj=obj.list(tWhere,0,0);
		}
   	   	StringBuffer sb = new StringBuffer("<html><body><table border='1'>");
   	    sb.append("<tr><td>设备名</td><td>设备别名</td><td>MAC地址</td><td>所属热点ID</td><td>AC</td><td>转换器名称</td><td>光纤名</td><td>覆盖类型</td>"
   	    +"<td>覆盖区域</td><td>IP地址</td><td>IP网关</td><td>SSID</td><td>标准</td><td>设备种类</td><td>设备位置</td><td>识别名</td><td>设备模型</td><td>设备供应商</td><td>操作人</td><td>操作时间</td></tr>");
	    if (vctObj.size() != 0)
	    {  
	        for (int i = 0; i < vctObj.size(); i++)
		    {
		    
		       sb.append("<tr><td> ");
		       sb.append((vctObj.get(i).getDevice_Name()==null?"":vctObj.get(i).getDevice_Name()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getDevice_Alias()==null?"":vctObj.get(i).getDevice_Alias()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getStrMac_Addr()==null?"":vctObj.get(i).getStrMac_Addr()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getStrHotSpot()==null?"":vctObj.get(i).getStrHotSpot()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getStrAc_Name()==null?"":vctObj.get(i).getStrAc_Name()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getStrSwitch_Name()==null?"":vctObj.get(i).getStrSwitch_Name()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getStrOnu_Name()==null?"":vctObj.get(i).getStrOnu_Name()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getStrCoverage_Type()==null?"":vctObj.get(i).getStrCoverage_Type()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getStrVocerage_Area()==null?"":vctObj.get(i).getStrVocerage_Area()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getStrIp_Addr()==null?"":vctObj.get(i).getStrIp_Addr()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getStrIp_Mask()==null?"":vctObj.get(i).getStrIp_Mask()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getStrSsId()==null?"":vctObj.get(i).getStrSsId()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getStrInter_Standard()==null?"":vctObj.get(i).getStrInter_Standard()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getStrDevice_Type()==null?"":vctObj.get(i).getStrDevice_Type()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getStrDevice_Position()==null?"":vctObj.get(i).getStrDevice_Position()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getIsEquence_Number()==null?"":vctObj.get(i).getIsEquence_Number()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getDevice_Model()==null?"":vctObj.get(i).getDevice_Model()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getDevice_Vendor()==null?"":vctObj.get(i).getDevice_Vendor()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getStrCreator()==null?"":vctObj.get(i).getStrCreator()));
		       sb.append("</td><td> ");
		       sb.append((vctObj.get(i).getDtCreatDate()==null?"":vctObj.get(i).getDtCreatDate()));
		       sb.append("</td></tr> ");
		      
		    }
		    if(vctObj.size()==1){  	 
		        sb.append("<tr><td> </td><td></td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>");
			 }
		    
	    }
   	   	sb.append("</table></body></html>");
   	   	System.out.println(sb);
	    String strFileName = "AP信息表.xls";//自定义xls文件的文件名
	    response.setCharacterEncoding("utf-8");
	    response.setContentType("APPLICATION/*;charset=utf-8");
	    response.setHeader( "Content-Disposition", "attachment;filename="  + new String( strFileName.getBytes("gbk"), "ISO8859-1"));
	    out.clearBuffer(); 
	    out = pageContext.pushBody();
	    ServletOutputStream output = response.getOutputStream();
	    System.out.println(sb.toString().getBytes("utf-8"));
	    output.write(sb.toString().getBytes("utf-8"));
	  //out.clearBuffer(); 
	//  WarnAppear.shareMethodForExport(sb,strFileName,response,out,pageContext);
 
	
%>
<%@ include file="../include/jsp/footer.jsp"%>
